<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

      <#include "/common/elibs.html">
	
</head><body><div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">首页</a>
        <a href="#">后期阶段</a>
        <a>
          <cite>复检</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
      <i class="layui-icon" style="line-height:30px">ဂ</i></a>
  </div><div class="x-body">
    <div class="layui-row">
      <table class="layui-hide" id="test" lay-filter="test"></table><script type="text/html" id="toolbarDemo">
        
      </script>
      <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="add">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">修改内容</a>
      </script>
    </div></div><script>
        var index = 42;
        isToken();
      layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test'
            ,url:  path+'/pc/project/getIntermediateInspectionList'
            ,toolbar: '#toolbarDemo'
            ,title: '项目数据表'
            ,headers:{'X-USER-TOKEN':localStorage.getItem("token")}
            ,where: {"status":index,"testType":1}
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'idProAdmin',type:'numbers', title:'ID', width:80, fixed: 'left' }
                ,{field:'customerName', title:'客户名称', width:200 }
                ,{field:'customerPhone', title:'联系电话', width:150}
                ,{field:'electricTotalCapacity', title:'报装容量'}
                ,{field:'reExaminationFrequency', title:'检查次数'}
                ,{field: 'status', title: '操作类型',
                    templet: function (d) {
                        var html = '';
                        if(d.status < index){//项目状态不到当前进度 并且提交状态为0不给予任何操作
                            html = '';
                        }else if((d.status > index || d.status === index) && d.submitState > 0 && isNotNull(d.idProReExamination)){//项目状态大于或等于当前进度 并且提交状态大于0给予修改操作
                            html += '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">修改数据</a>';
                        }else if(d.status === index && d.submitState === 0 || isNull(d.idProReExamination)){//项目状态为当前进度 并且提交状态小于3给予添加操作
                            html += '<a class="layui-btn layui-bt0n-primary  layui-btn-xs" lay-event="add">添加数据</a>';
                        }else {
                            html += '<a class="layui-btn layui-btn-danger layui-btn-xs">未知状态</a>';
                        }
                        if(isNotNull(d.idProReExamination) && d.count1 > 0 && d.submitState < 3){
                            html += '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="add">下次复检</a>';
                        }
                        return html;
                    }}
            ]]
            ,request: {
                pageName: 'currentPage' //页码的参数名称，默认：page
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.totalResult, //解析数据长度
                    "data": res.data.data //解析数据列表
                }
            }
            , page: true
            , limit: 10
            , id: 'testReload'
        });
        var $ = layui.$, active = {reload: function(){
            var tcaParentsId = $("#tcaParentsId").val();
            var tcaName =  $("#tcaName").val();
            if(tcaParentsId == "" && tcaName == ""){
              return;
            }
            table.reload('testReload',{
              where: { //设定异步数据接口的额外参数，任意设
                tcaParentsId: tcaParentsId
                ,tcaName: tcaName
              }
              ,page: {
                curr: 1 //重新从第 1 页开始
              }
            }); //重载表格
          }}
        $('#sreach').on('click', function(){
          var type = $(this).data('type');
          active[type] ? active[type].call(this) : '';
        });//监听行工具事件
        table.on('tool(test)', function(obj){
          var data = obj.data;
          //console.log(obj)
          if(obj.event === 'edit'){
            window.location.href = '${request.contextPath}/modules/project/threePro/fj/edit.html?id='+obj.data.idProAdmin+'&subsetId='+obj.data.idProReExamination;
          } else if(obj.event === 'add'){
            window.location.href = '${request.contextPath}/modules/project/threePro/fj/add.html?id='+obj.data.idProAdmin;
          }
        });});
    </script></body></html>